----------------------------------------------------------------------------------
-- Company: 
-- Engineer: 
-- 
-- Create Date:    22:02:13 04/10/2010 
-- Design Name: 
-- Module Name:    PixelDriver - Behavioral 
-- Project Name: 
-- Target Devices: 
-- Tool versions: 
-- Description: 
--
-- Dependencies: 
--
-- Revision: 
-- Revision 0.01 - File Created
-- Additional Comments: 
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity PixelDriver is
    Port ( hcount : in  STD_LOGIC_VECTOR (10 downto 0);
           vcount : in  STD_LOGIC_VECTOR (10 downto 0);
           xpos : in  STD_LOGIC_VECTOR (10 downto 0);
           ypos : in  STD_LOGIC_VECTOR (10 downto 0);
           red : out  STD_LOGIC_VECTOR (2 downto 0));
end PixelDriver;

architecture Behavioral of PixelDriver is
begin
	PROCESS(hcount, vcount, xpos, ypos)
		VARIABLE x : SIGNED(10 downto 0);
		VARIABLE y : SIGNED(10 downto 0);
		VARIABLE hcnt : SIGNED(10 downto 0);
		VARIABLE vcnt : SIGNED(10 downto 0);
	BEGIN
		x := SIGNED(xpos);
		y := 480-SIGNED(ypos);
		hcnt := SIGNED(hcount);
		vcnt := SIGNED(vcount);
	
		red <= "000";
		--draw a 5x5 red square at the current position
		IF hcnt >= x-5 and hcnt <= x+5 and vcnt >= y-5 and vcnt <= y-5 THEN
			red <= "111";
		END IF;
	END PROCESS;
end Behavioral;

